//1．重新编写复习题5，用月份名的拼写代替月份号（别忘了使用strcmp()）。在一个简单的程序中测试该函数。

#include <stdio.h>
#include <string.h>

struct month {
    char name[10];
    char abbr[4];
    int days;
    int monumb;
};

int main(int size, char **argv) {
    struct month months[12] = {
            {"January",   "jan", 31, 1},
            {"February",  "feb", 28, 2},
            {"March",     "mar", 31, 3},
            {"April",     "apr", 30, 4},
            {"May",       "may", 31, 5},
            {"June",      "jun", 30, 6},
            {"July",      "jul", 31, 7},
            {"August",    "aug", 31, 8},
            {"September", "sep", 30, 9},
            {"October",   "oct", 31, 10},
            {"November",  "nov", 30, 11},
            {"December",  "dec", 31, 12}
    };
    int monthNumber = 0;
    if (size < 2) {
        fputs("Usage exe monthName \n", stderr);
        return 0;
    }
    for (int j = 0; j < 12; ++j) {
        if (strcmp(argv[1], months[j].name)==0) {
            monthNumber = months[j].monumb;
        }
    }
    if (monthNumber == 0) {
        printf("Give a name of month");
        return 0;
    }


    int sumDay = 0;
    for (int i = 0; i < 12; ++i) {
        if (months[i].monumb <= monthNumber) {
            sumDay += months[i].days;
        }
    }
    printf("monumb1-monumb%d has %d days\n", monthNumber, sumDay);
}